﻿/********************************************************************************
** @ Date:2025/04/23
** @ Author: Gaojia
** @ Description:
** @ Version:1.0.0
** @ Fun:
********************************************************************************/
#ifndef CPublicData_H
#define CPublicData_H
#include "dbstruct.h"

const QString g_sTableName = "palarm_state";

//typedef ISqlOper* (*CreateISqlOperFunc)();

struct SmartControlConfig 
{
	QString dbName;
	QString dbPort;
	QString dbHost;
	QString dbUser;
	QString dbPassword;
	quint16 websocketPort;
	QString httpUrl;
};
class Robot;
class CWebSocketSrvThread;
class CPublicData
{
public:
	static CPublicData& instance()
	{
		static CPublicData instance;
		return instance;
	}
public:
	bool initSql();         //初始化数据库
	bool getConfig();       //获取配置文件 
	bool saveConfig();      //保存配置文件
	bool m_bInit;
	bool m_bConfig;         //是否加载过配置文件 
	bool m_bSqlInit;        //是否初始化过数据库
	bool init();            //初始化
	CSqlDllOper *m_pSqlDllOper;   //数据库操作对象
	int m_nWebSocketPort;    //数据库监听端口号
	QString m_sCustomName;
	QString m_sHttpUrl;    //HttpUrl地址前缀
	QString m_sPdfOutputPath;
	CWebSocketSrvThread* m_pWebSocketSrv;					//websocket服务线程类
	QMap<QString, Robot*>m_pMapIFDev;   //设备对象数组
private:
	// 加载 DLL 并缓存其 create/destroy 函数
	//bool loadLibrary();
private:
	CPublicData();
	~CPublicData();
	QString m_sConnectInfo; //数据库连接信息
	SmartControlConfig* m_pConfig;//机器人配置信息
};

#endif